home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / comm / irc / Bork_AmIRX.lha / bork.amirx < prev    next >
Encoding:
Text File  |  1998-01-27  |  3.2 KB  |  107 lines

  1. /*
  2. /// Bork.AMIRX v2.0
  3. \\\ Originally written by Andrew Rooney (IRC: Dustbin) dustbin@hp9000.eita8net.com
  4. /// Updated by John Oberg (IRC: Kuda) kuda@mindless.com
  5. \\\ Much of this script ripped off from Ariel Magnum's re-write of aminetfind.gvrexx :)
  6. ///
  7. \\\ Extended cmd parsing and handling
  8. /// so you can now use the AmIRC RAW output commands as :
  9. \\\ /bork "Hello there!" raw notice Kuda
  10. /// will send the results to me via notice but will not be displayed on your
  11. \\\ amirc lister(hence RAW).
  12. /// 
  13. \\\ Usage:
  14. /// /alias bork rx bork.amirx %p
  15. \\\ /bork "Text to be Encheferized" [output]
  16. ///
  17. \\\ Output is the command that will be launched with the results as the argument
  18. ///
  19. \\\ Examples:
  20. /// /bork "Hello there" echo
  21. \\\ «Bork» | Hellu zeere-a
  22. /// ...
  23. \\\
  24. /// Other examples:
  25. \\\ /bork "Hello there" msg josef    - sends output in a message to josef
  26. /// /bork "Hello there" say          - sends output to the channel
  27. \\\ /bork "Hello there" me           - sends output to the channel as an action
  28. /// /bork "Hello there" topic        - sets channel topic to "Hellu zeere-a"
  29. \\\
  30. /// Notes:
  31. \\\ o  You MUST put the text to be encheferized in quotes.
  32. /// o  Quotes must be " quotes, not ' quotes.
  33. \\\ o  - options MUST be the last options on the line.
  34. /// o  output defaults to echo
  35. \\\
  36. /// Hints:
  37. \\\ Here's how I've got my script set up...
  38. /// /alias borks /rx bork.amirx "%p" say  - sends output to channel without having to put text in quotes
  39. \\\ /alias borke /rx bork.amirx "%p"      - echos output to screen without having to put text in quotes
  40. /// /alias borka /rx bork.amirx "%p" me   - sends output to chan. as action (no need for quotes)
  41. \\\ /alias bork /rx bork.amirx %p         - for everything else (gotta use quotes with this one)
  42. (*/
  43.  
  44. if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then do
  45.         'echo P=«Aminet» You need rexxsupport.library version 30 or greater in libs:'
  46.         exit 10 
  47. end
  48.  
  49. bold=d2c(2)
  50.  
  51. parse arg cmds
  52. if index(cmds,'"')>0 then do
  53.         parse var cmds '"'text'"' cmd
  54. end
  55. else do
  56.         parse var cmds text' 'cmd
  57. end
  58.  
  59. if cmd='' then cmd='echo'
  60. text=strip(text)
  61. otext='Borking: '
  62. otext=otext||bold||text||bold
  63. cmd=strip(cmd)
  64. if cmd~='' then otext=otext||', output command 'bold||cmd||bold
  65. otext=otext||'.'
  66. if address()='REXX' then say 'Borking 'name
  67. else 'echo P=«Bork» 'otext
  68.  
  69. outcmd=cmd
  70. Select
  71. when upper(outcmd)='ECHO' then outcmd='ECHO P=«Bork»'
  72. when pos('RAW',upper(outcmd))=1 then do
  73.   parse var outcmd . tcmd tnick
  74.   outcmd='RAW' tcmd tnick ':'
  75. end
  76. when upper(outcmd)~='SAY' then outcmd='SAY /'outcmd
  77. otherwise
  78. end
  79.  
  80. If Exists('T:AmIRCBork1') then do
  81.   If ~Delete('T:AmIRCBork1') then say ECHO BORK: Unable to delete file T:AmIRCBork1'
  82. End
  83.  
  84. If Exists('T:AmIRCBork2') then do
  85.   If ~Delete('T:AmIRCBork2') then say ECHO BORK: Unable to delete file T:AmIRCBork2'
  86. End
  87.  
  88. If Open(file,'T:AmIRCBork1',W) then do
  89.   Call Writeln(file,text)
  90.   Call Close(file)
  91.   Address command 'C:Chef <T:AmIRCBork1 >T:AmIRCBork2'
  92.   If Open(file,'T:AmIRCBork2') then do
  93.     Bork = Readln(File)
  94.     outcmd' 'bork
  95.     Call Close(File)
  96.     Exit
  97.   End
  98.   Else do
  99.     'ECHO BORK: Unable to open temp file T:AmIRCBork2 (readmode)'
  100.     Exit
  101.   End
  102. End
  103. Else do
  104.   'ECHO BORK: Unable to open temp file T:AmIRCBork1 (write mode)'
  105.   Exit
  106. End
  107.